Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHANGE(pmd): @W-16866602@: Update PMD to version 7.6.0 #1638

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

stephen-carter-at-sf
Copy link
Collaborator

No description provided.

@stephen-carter-at-sf stephen-carter-at-sf merged commit 70a0201 into dev Oct 1, 2024
13 checks passed
@stephen-carter-at-sf stephen-carter-at-sf changed the title CHANGE(pmd): @W-16113765@: Update PMD to version 7.6.0 CHANGE(pmd): @W-16866602@: Update PMD to version 7.6.0 Oct 1, 2024
@abhidev1108
Copy link

Hello @stephen-carter-at-sf ,

Could you please suggest from where to download the complete library for sfsx-scanner since it has the PMD included.

In my project we are using below structure to install sfdx-scanner plugin via commit.

sfdx scanner

@stephen-carter-at-sf stephen-carter-at-sf deleted the sc/W-16113765 branch October 11, 2024 14:06
@abhidev1108
Copy link

Hello Guys,

i am using sfdx-scanner for my project and custom PMD rule set for the static code analysis.
When i upgraded the scanner to 4.0.0, PMD was upgrade to 7.0.0 but then i started getting error in my pipeline. The same rule set is working fine with sfdx-scanner 3.25 version. I have attached the error log file.

PMD error.txt

@abhidev1108
Copy link

Also, i am attaching the ruleset file
PMD rule set.txt

@stephen-carter-at-sf
Copy link
Collaborator Author

stephen-carter-at-sf commented Nov 7, 2024

@abhidev1108 ... can you please create a proper issue over at https://github.com/forcedotcom/sfdx-scanner/issues/new/choose instead of posting comments on a PR.

Also, note that PMD has changed quite a bit from version 6 to version 7 - so you may need to make changes to your ruleset file. So first read through https://docs.pmd-code.org/latest/pmd_userdocs_migrating_to_pmd7.html to see if you need to make any changes. If you still are having trouble, then please put the exact error message that you are seeing when filling out the form to create an issue.

But note that most likely your issue is PMD specific and not Code Analyzer specific. So I'll also ask you to download PMD independently from code analyzer and attempt to use your ruleset with PMD directly if you are still having issues to verify whether or not the error appears independent of code analyzer.

--- UPDATE ---
I see you added in a file that contains errors... which confirm my suspicions. The errors like

2024-11-04T07:40:49.3666791Z  11|          <property name="cc_categories" value="Complexity" />
2024-11-04T07:40:49.3667364Z               ^^^^^^^^^ Cannot set non-existent property 'cc_categories' on rule ExcessiveClassLength

are indeed PMD specific errors showing that you need to update your ruleset file to be compatible with PMD 7. This is not an issue with Code Analyzer

@stephen-carter-at-sf
Copy link
Collaborator Author

@abhidev1108 In fact... a quick google search of cc_categories and PMD shows that way back in PMD 6.55.0 the cc_categories (and many other rule properties) were deprecated: https://docs.pmd-code.org/pmd-doc-6.55.0/pmd_rules_apex_codestyle.html

So you indeed need to update your ruleset to stop using these fields which are no longer supported.

Lastly, it looks like your ruleset primarily just changes the priority of the rules and selects which rules you want to run.

May I recommend you look into the new Code Analyzer v5 which is currently in Developer Preview since it allows you to have far more fine grain control over which rules you want to run and allows you to configure the severity, tags, etc of each of the rules... without ever having to deal with PMD ruleset files. See https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/guide/version-5.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants